﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using PeonyShop.DAL;

namespace PeonyShop.Bussiness
{
    public class BImage
    {
        public BImage()
        { 
        }

        public bool InsertImage(string sName, string sDesc, string sImgPath, int CateId, int SubCateId, int ProductId, int iNewsId, DateTime dtInsert, int iImgOrder, bool IsShowHome, bool IsShowOwn, bool IsActive, bool IsDelete)
        {
            return new DAImage().InsertImage(sName, sDesc, sImgPath, CateId,SubCateId, ProductId, iNewsId, dtInsert, iImgOrder, IsShowHome, IsShowOwn, IsActive, IsDelete);
        }

        public DataSet GetImage( string sName, int iMainCate, int iSubCate, int iProductId, int IsShowHome, int IsShowOwn, int IsActive, bool IsDelete)
        {
            return new DAImage().GetImage(sName, iMainCate, iSubCate, iProductId, IsShowHome, IsShowOwn, IsActive, IsDelete);
        }

        public DataSet GetImgByCate(int iMainCate, int iSubCate, int iProductId)
        {
            return new DAImage().GetImgByCate(iMainCate, iSubCate,iProductId);
        }

        //public DataTable GetImgHomePage(string sName, int iCateId, int iSubCateId,int iProductId, int IsShowHome,int IsShowOwm, int IsActive, int IsDelete)
        //{
        //    return new DAImage().GetImgHomePage(CateHome, IsShowHome);
        //}

        public bool UpdateImage(int Id, string sName, string sDesc, string ImgPath, int iProductId, int Newsid, int iMainCateId, int iSubCateId, string sDate, int iImgOrder, int IsShowHome, int IsShowOwn, int IsActive, int IsDelete)
        {
            return new DAImage().UpdateImage(Id, sName, sDesc, ImgPath, iProductId, Newsid, iMainCateId, iSubCateId, sDate, iImgOrder, IsShowHome, IsShowOwn, IsActive, IsDelete);
        }

        public DataSet GetOtherImgShowHome(int IsActive, int IsShowHome)
        {
            return new DAImage().GetOtherImgShowHome(IsActive, IsShowHome);
        }

        public DataTable GetAllImgShowHome(string sName, int iMainCate, int iSubCate, int iProductId, int IsShowHome, int IsShowOwn, int IsActive, bool IsDelete)
        {
            DataSet ds = GetImage(sName, iMainCate, iSubCate, iProductId, IsShowHome, IsShowOwn, IsActive, IsDelete);
            DataTable dtInCate = new DataTable();
            if (ds != null)
            {
                dtInCate = ds.Tables[0];
            }
            ds = GetOtherImgShowHome(IsActive, 1);
            DataTable dtOther = new DataTable();
            if(ds != null)
                dtOther = ds.Tables[0];

            dtInCate = dtOther.Clone();
            foreach (DataRow dr in dtOther.Rows)
            {
                dtInCate.ImportRow(dr);
            }

            return dtInCate;
        }
    }
}
